#include "../Socket.hpp"

int main(int argc, char *argv[])
{
    if (argc != 3)
    {
        std::cerr << "usage: " << argv[0] << " serverIP serverPORT" << std::endl;
        exit(0);
    }
    std::string ip = argv[1];
    uint16_t port = std::stoi(argv[2]);
    Socket clt;
    clt.CreateClient(port, ip);

    while (true)
    {
        char buf[1024] = {0};
        std::cin >> buf;
        clt.Send(buf, sizeof(buf));
        std::cout << "send success" << std::endl;
        int n = clt.Recv(buf, 1023);
        buf[n] = 0;
        std::cout << buf << std::endl;
    }

    clt.Close();
    return 0;
}